package com.bci.pwtz.service;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.bci.pwtz.common.util.MutiPatternParser;
import com.bci.pwtz.common.util.PaginationList;
import com.bci.pwtz.exception.InvalidParametersException;
import com.bci.pwtz.exception.PwtzDatabaseException;
import com.bci.pwtz.mysql.model.SensitiveWord;

public interface SensitiveWordService
{
    /**
     * 添加敏感词
     * 
     * @param sensitiveWord
     * @return
     * @throws PwtzDatabaseException
     */
    SensitiveWord add(SensitiveWord sensitiveWord) throws PwtzDatabaseException;

    /**
     * 删除敏感词
     * 
     * @param sensitiveWordId
     * @return
     * @throws PwtzDatabaseException
     */
    int delete(Long sensitiveWordId) throws PwtzDatabaseException;

    /**
     * 修改敏感词
     * 
     * @param sensitiveWord
     * @return
     * @throws PwtzDatabaseException
     */
    int upadte(SensitiveWord sensitiveWord) throws PwtzDatabaseException;

    /**
     * 获取敏感词集合
     * 
     * @param date
     * @return
     * @throws PwtzDatabaseException
     */
    PaginationList<SensitiveWord> selectSensitiveWords(String beginTime, String endTime, int pageSize, int pageNo) throws PwtzDatabaseException;

    /**
     * 获取敏感词
     * 
     * @param sensitiveWordId
     * @return
     * @throws PwtzDatabaseException
     */
    SensitiveWord load(Long sensitiveWordId) throws PwtzDatabaseException;

    /**
     * 查询指定内容当中匹配指定等级集合敏感词的集合<br/>
     * <p>
     * Description: 查询指定内容当中匹配指定等级集合敏感词的集合 <br/>
     * <p>
     * Author: Sam<br/>
     * <p>
     * Date: 2013-6-14-上午10:12:04<br/>
     * <p>
     * 
     * @param content
     *            指定要匹配的内容
     * @param level
     *            敏感词级别
     * @return
     * @throws InvalidParametersException
     * @throws UppDataBaseException
     * 
     */
    public Map<Integer, List<String>> match(String content, int[] levels) throws InvalidParametersException;

    /**
     * 一句话描述 <br/>
     * <p>Description: TODO(详细描述) 
     * <br/>
     * <p>Author: tonic<br/>
     * <p>Date: 2014-9-26-下午4:13:36<br/>
     * <p>
     * @return
     * @throws PwtzDatabaseException   
     * 
     */
    ConcurrentHashMap<Short, MutiPatternParser> initMutiPatternParserMap() throws PwtzDatabaseException;
    
    public boolean matchContent(String content, int[] levels) throws InvalidParametersException;
    
    public List<SensitiveWord> selectSensitiveWordList()throws PwtzDatabaseException;
}
